﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Game
{
    namespace RenderTechnique
    {
        public class Light
        {
            private IDK.Vector3 mPosition;
        }

        public class TechniqueDescription
        {
            public TechniqueDescription(IDK.Core core, IDK.Renderer render, IDK.Camera camera)
            {
                Core = core;
                Renderer = render;
                Camera = camera;
            }

            public IDK.Core Core
            {
                get;
                set;
            }

            public IDK.Renderer Renderer
            {
                get;
                set;
            }

            public IDK.Camera Camera
            {
                get;
                set;
            }
        }

        public abstract class OutputTechnique
        {
            protected List<Light> mLights;
            protected IDK.ShaderProgram mBaseShader;

            private IDK.SceneNode mRootObjectSceneNode;

            private IDK.RenderTarget mOutput;

            private TechniqueDescription mDesc;

            public OutputTechnique(TechniqueDescription desc)
            {
                mDesc = desc;
            }

            public TechniqueDescription Description
            {
                get { return mDesc; }
            }

            public IDK.RenderTarget RTTOutput
            {
                get { return mOutput; }
            }

            public IDK.SceneNode RootObjectSceneNode
            {
                get { return mRootObjectSceneNode; }
                set { mRootObjectSceneNode = value; }
            }

            public IDK.RenderTarget Output
            {
                get { return mOutput; }
            }

            public IDK.ShaderProgram BaseShader
            {
                get { return mBaseShader; }
            }

            public virtual void Init()
            {
                //Make default root
                RootObjectSceneNode = Description.Core.GetScene().AddNode("Root", null);
            }

            public void InitOutput()
            {
                //add output target
                mOutput = Description.Core.GetRenderTarget("rttOutput");
                mOutput.AttachTexture(Description.Core.CreateRenderTexture(
                    Description.Renderer.GetViewport().Width,
                    Description.Renderer.GetViewport().Height,
                    IDK.Texture.Format.RGBA, IDK.Texture.PixelType.ByteRGBA8));
            }

            public void AddLight(Light light)
            {
                mLights.Add(light);
            }

            public virtual void Update(Events.ProcessSceneUpdate evnt)
            {
                //do nothing
            }
        }
    }
}
